#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define all(x) (x).begin(),(x).end()
typedef long long ll;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<VI> VVI;

typedef pair<int,int> PII;
typedef vector<PII> VPII;
#define X first
#define Y second
#define mp make_pair

#define two(x) (1<<(x))
#define twoll(x) ((long long)1<<(x))
#define contain(s,x) (((s)&two(x))!=0)
#define containll(s,x) (((s)&twoll(x))!=0)

#define db(a) cout << #a << "=" << a << " "
#define dbn cout << endl
#define sqr(x) (x)*(x)

string STR(int n) { char tmp[20]; sprintf(tmp,"%d",n); return tmp; }
int INT(string s) { return atoi(s.c_str()); }
template <class Ty, class Tx> Ty to(const Tx &x) { Ty y; stringstream ss; ss<<x; ss>>y; return y; }

const int INF = 1000000007;
const double EPS = 1e-10;

char buf[1<<20];
int TC;

int N,S,K;
set<int> con[1001];
int D[1001];
bool ok[1001];
bool visit[1001];

int getD(int s) {
	int &ret = D[s];
	if (ret != -1)
		return ret;
	ret = -INF;
	bool isC = 0;
	for (set<int>::iterator it = con[s].begin(); it != con[s].end(); ++it)
		if (D[*it] == -1)
			ret = max(ret,getD(*it)+1), isC = 1;
	if (!isC)
		if (ok[s])
			return -INF;
		else
			return 0;
	else
		return ret;
}

void mark(int s, int d) {
	if (d > K)
		return;
	visit[s] = 1;
	bool isC = 0;
	for (set<int>::iterator it = con[s].begin(); it != con[s].end(); ++it)
		if (!visit[*it])
			mark(*it,d+1), isC = 1;
	if (!isC)
		ok[s] = 1;
}

int main() {
#define SUBMIT 1
#if !SUBMIT
	freopen("DATA.in", "rt", stdin);
	freopen("DATA.ou", "wt", stdout);
#endif

	gets(buf); TC = atoi(buf);
	
	while (TC--) {
		memset(ok,0,sizeof(ok));
		scanf("%d%d%d",&N,&S,&K);
		--S;
		for (int i = 0; i < N; ++i)
			con[i].clear();
		for (int i = 0; i < N-1; ++i) {
			int a,b;
			scanf("%d%d",&a,&b);
			a--,b--;
			con[a].insert(b);
			con[b].insert(a);
		}
		
		memset(D,-1,sizeof(D));
		int d = getD(S);
		int res = 0;
		memset(visit,0,sizeof(visit));
		mark(S,0);
		while (d > K) {
			for (int i = 0; i < N; ++i)
				if (D[i] == K) {
					memset(visit,0,sizeof(visit));
					mark(i,0), ++res;
				}
			memset(D,-1,sizeof(D));
			d = getD(S);
		}
		printf("%d\n",res);
	}

	return 0;
}





